package com.project.storage.controller;

import com.project.common.RespResult;
import com.project.storage.service.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: seata-at
 * @description: 库存
 * @author: mml
 * @create: 2023/12/19
 */
@RestController
@RequestMapping("/storage")
public class StorageController {

    @Autowired
    private StorageService storageService;

    @PostMapping("/deduct")
    public RespResult deduct(String projectId, Integer count) {
        boolean deduct = storageService.deduct(projectId, count);
        return deduct ? RespResult.success("库存扣除成功") : RespResult.error("库存扣除失败");
    }
}
